import { default as request } from '@/framework/utils/request';
import { ID, ResultData } from 'hbisdt-design';
import { ExcelType } from './types';

/**
 * 新建Excel
 * @param data
 * @returns
 */
export const saveExcel = (data: ExcelType) => {
  return request({
    method: 'POST',
    url: '/excel/save',
    data
  });
};

/**
 * 编辑Excel
 * @param data
 * @returns
 */
export const editExcel = (data: ExcelType) => {
  return request({
    method: 'POST',
    url: '/excel/edit',
    data
  });
};

/**
 * 删除Excel
 * @param id
 * @returns
 */
export const deleteExcel = (id: ID) => {
  return request({
    method: 'DELETE',
    url: `/excel/delete`,
    params: { id }
  });
};

/**
 * 获取Excel列表
 * @param params
 * @returns
 */
export const getExcelList = (): Promise<
  ResultData<{ records: ExcelType[] }>
> => {
  return request({
    method: 'GET',
    url: '/excel/page',
    params: { pageNo: 1, pageSize: 100000 }
  });
};
